<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="<?php echo $this->root_dir;?>/static/common/css/common.css" type="text/css" rel="stylesheet">
<link href="<?php echo $this->root_dir;?>/static/common/css/style.css" type="text/css" rel="stylesheet">
<link href="<?php echo $this->root_dir;?>/static/common/css/admin-header.css" type="text/css" rel="stylesheet">
<meta http-equiv="x-ua-compatible" content="ie=7" />
<script type="text/javascript" src="<?php echo $this->root_dir;?>/static/common/js/jquery.min.js"></script>
<script src="<?php echo $this->root_dir;?><?php echo $this->root_dir;?>/static/common/js/frame.js" type=text/javascript></script>
<script type="text/javascript" src="<?php echo $this->root_dir;?>/static/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="<?php echo $this->root_dir;?>/static/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="<?php echo $this->root_dir;?>/static/common/js/jquery1.42.min.js"></script>
<script type="text/javascript" src="<?php echo $this->root_dir;?>/static/common/js/jquery.SuperSlide.2.1.js"></script>
<script type="text/javascript" src="<?php echo $this->root_dir;?>/static/common/js/template.js"></script>
<script type="text/javascript">
//选项卡
function nTabs(thisObj,Num){
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length; i++)
	{
	  if (i == Num)
	  {
	   thisObj.className = "active"; 
		  document.getElementById(tabObj+"_Content"+i).style.display = "block";
	  }else{
	   tabList[i].className = "normal"; 
	   document.getElementById(tabObj+"_Content"+i).style.display = "none";
	  }
	} 
}

function delete_menu(obj, menuid){
	$.getJSON('<?php echo $this->createUrl('UpdateShortcutMenu')?>', {menuid: menuid}, function(data){
		parent.shortcut();
	});
	
	$(obj).parent().parent().remove();
}


function add_menu(obj, menuid){
	$.getJSON('<?php echo $this->createUrl('UpdateShortcutMenu')?>', {menuid: menuid, shortcut: 1}, function(data){
		shortcut();
		parent.shortcut();
	});
}

function shortcut(){
    $.getJSON('<?php echo $this->createUrl('GetShortcutMenu')?>', {}, function(data){
		var div = '.shortcutMenu-list';
		var source = $(div).first().html();
		var render = template.compile(source);
		var html = render({
			list: data
		});
		$(div).eq(1).html(html);
	});
}
</script>
</head>
<body>

  <div class="content" id="con">

    <div class="add-con">
      <ul class="dele shortcutMenu-list hidden">
        {{each list as v i}}
        <li><a href="javascript:;">{{v.name}}<span title="删除" onclick="delete_menu(this, '{{v.menuid}}')">ⅹ</span></a></li>
        {{/each}}              
      </ul>
      <ul class="dele shortcutMenu-list"></ul>     
      
      
      <!-- 选项卡 -->
      <div class="nTab"> 
        <!-- 标题 -->
        <div class="TabTitle">
          <ul id="myTab0">
          <?php
		$i = 0;
        if (isset($this->menu['parent'])) foreach($this->menu['parent'] as $k=>$v){			
		?>
            <li<?php if($i==0) echo ' class="active"';?> onclick="nTabs(this,<?php echo $i;?>);"><a href="#"><?php echo $v['name'];?></a></li>
        
        <?php
		$i++;
		}
		?>
          </ul>
        </div>
        <!-- 内容 -->
        <div class="TabContent">
         <?php
		 $tree = new Tree;
		 $tree->init($this->menu['data']);
			$i = 0;
			if (isset($this->menu['parent'])) foreach($this->menu['parent'] as $k=>$v){	
			$child = $tree->get_child($k);		
			?>
          <div id="myTab0_Content<?php echo $i?>"<?php echo $i!=0 ? ' class="hidden"' : ''?>>
          <?php if ($child) foreach($child as $kk=>$vv){
			  $childs = $tree->get_child($kk);
		  ?>
          
            <h6><a href="javascript:;" onclick="add_menu(this, <?php echo $vv['menuid'];?>);"><?php echo $vv['name'];?></a></h6>
            <ul class="changeDele">
            <?php if ($childs) foreach($childs as $kkk=>$vvv){?>
              <li class="disabled" onClick=""><span title="点击添加快捷菜单">﹢</span><a href="#"><?php echo $vvv['name'];?></a></li>
              <?php
			  }
			  ?>
            </ul>
            <?php
		  }
		  ?>
            
          </div>
          <?php
			$i++;
			}
			?>
        </div>
      </div>
      <!-- 选项卡结束 --> 
      
    </div>

  </div>


<script type="text/javascript">
$(function(){
    shortcut();
});
</script>


</body>
</html>